package com.jg.config;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;

import javax.servlet.Filter;

/**
 * @author 86130
 * @version 1.0
 * @description: TODO
 * @date 2025/6/9 上午9:54
 */
public class WebConfig01 {
        /*extends AbstractDispatcherServletInitializer {
    // 创建springMVC容器
    @Override
    protected WebApplicationContext createServletApplicationContext() {
        //  创建springMVC容器
        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
        ctx.register(SpringMVCConfig.class);
        System.out.println("创建springMVC容器");
        return ctx;
    }

    // 映射
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    //  创建spring容器
    @Override
    protected WebApplicationContext createRootApplicationContext() {
        return null;
    }

    //  创建过滤器，解决中文乱码
    @Override
    protected Filter[] getServletFilters() {
        CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
        encodingFilter.setEncoding("UTF-8");
        return new Filter[]{encodingFilter};
    }*/
}
